class_name PlayerRunState
extends State


func _init() -> void:
	super("run")


func _on_setup() -> void:
	add_component(AnimationStateComponent.new("player_animation", owner.animator, "run"))
	add_component(TagStateComponent.new("player_tags", [
		GameplayTagLibrary.State_Ground_Stand,
		GameplayTagLibrary.State_Ground_Move_Run]))


func _on_enter() -> void:
	owner.velocity = Vector2.ZERO


func _on_update(delta: float) -> void:
	var movement_input: float = owner.input_handler.get_axis("move_left", "move_right")
	owner.velocity.x = movement_input * owner.attribute_manager.get_attribute("run_speed").current_value * delta

	if movement_input * owner.face_direction < 0:
		owner.flip()
